<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
         function getRandom(min,max) {
            return Math.floor(Math.random()*(max-min+1))+min;
        }
        var random=getRandom(1,50);
        var num2=0;
        while(true){
            var num=prompt("你来猜数字,输入1~50的数");
            if(num>random){
                alert('猜大了');
                num2++;
            }else if(num<random){
                alert("猜小了");
                num2++;
               
            }else if(num==random){
                alert("你猜对了");
                break;
            }
            if(num2>10){
                alert("你没机会了");
                break;
            }

        }
    </script>
</head>
<body>
    
</body>
</html>